import { globalIgnores } from "eslint/config";
import { defineConfigWithVueTs, vueTsConfigs } from "@vue/eslint-config-typescript";
import pluginVue from "eslint-plugin-vue";
import { fileURLToPath } from "node:url";
import path from "node:path";

/* ---这里是重点--- */
// Get current directory as absolute path
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/* ---这里是重点--- */

// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
// import { configureVueProject } from '@vue/eslint-config-typescript'
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
export default defineConfigWithVueTs(
  {
    name: "app/files-to-lint",
    files: ["**/*.{ts,mts,tsx,vue}"],
    /* ---这里是重点--- */
    languageOptions: {
      parserOptions: {
        tsconfigRootDir: __dirname,
      },
    },
    rules: {
      // 将未使用的变量改为警告
      "no-unused-vars": "warn",
      // 如果使用 TypeScript，还需要配置 TypeScript 的未使用变量规则
      "@typescript-eslint/no-unused-vars": "warn",
    },
  },

  globalIgnores(["**/dist/**", "**/dist-ssr/**", "**/coverage/**"]),

  pluginVue.configs["flat/essential"],
  // vueTsConfigs.recommended
);
